<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>选中店铺</title>
<script src="${contextPath}/scripts/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/common.js" type="text/javascript"></script>
		<script src="${contextPath}/scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<link href="${contextPath}/styles/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="xt_main_right_center">
<form name="searchForm" id="searchForm" method="post" action="selectCheckShopUser.do">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
	<tr>
	  <td class="left-td-width-bg"  width="86" align="right">店名:</td>
	  <td class="right-td-width-bg-left" width="217" align="center">
	  <input class="input"  type="text"name="shopName" value="${shopName }" id="textfield"></td>
    </tr>
	<tr>
    	<td style="background:url(${contextPath}/images/xt_main_right_dhbj.jpg) repeat-x; "colspan="2" align="center">
    	<input type="submit" name="button2" class="btn_query" id="but" value="">
        <input type="reset" name="button" onClick="clearForm(this.form);return false;" class="btn_clear_form"  id="button" value=""></td>
    </tr>
</table>
</form>
</div>
 <table width="100%" border="0">
    <tr>
      <td align="left"><font color="#0066CC"><strong>查询结果：</strong></font></td>
    </tr>
  </table>
  <table  width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td class="top-td-width-bg" width="16%">&nbsp;</td>
      <td class="top-td-width-bg" width="16%" height="43">序号</td>
      <td class="top-td-width-bg" width="51%">店名</td>
    </tr>
    <s:iterator value="page.result" status="i" id="u">
    <tr>
      <td class="down-center-td-width-bg">  
      <input name="radio" type="checkBox" id="radio" value="${i.count }">
      <input type="hidden" name="shopNm" value="${u.name }"/>
      <input type="hidden" name="shopId" value="${u.objectId }"/>
      </td>
      <td class="down-center-td-width-bg">${i.count }</td>
      <td class="down-center-td-width-bg"><a href="javascript:buildOne('${u.objectId }','${u.name }')">${u.name }</a></td>
    </tr>
    </s:iterator> 
    <tr>
      <td colspan="4" align="center">    
      		<input type="hidden" id="allIds" name="allIds" value="<s:property value='allIds'/>" />
      		<input type="button" onclick="buildAll()" class="btn_qd" value="  "/>
      		<input type="button" value="  " class="btn_return" onclick="window.close()"/>
      </td>
    </tr>
   
  </table>
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="99%" colspan="13" align="right"><%@ include file="/WEB-INF/view/common/pagination.jsp"%></td>
    </tr>
  </table>
  <p>&nbsp;</p>

<script type="text/javascript">
function jumpPage(page) {
	var searchForm = document.searchForm;
	searchForm.action = "<s:property value='contextPath'/>/system/treaty/selectCheckShopUser.do?currentPage=" + page;
	searchForm.submit();
}
function buildOne(ids,names){
	window.opener.choose_shop(ids,names);
	window.close();
}
function buildAll(){
	var check = $("input[name='radio']:checked"); //得到所有被选中的checkbox
	var shopNames = $("input[name='shopNm']");
	var shopIds = $("input[name='shopId']");
	   var ids="";              //定义变量
	   var names="";
	   check.each(function(i){  
		   //循环拼装被选中项的值
	   		var j = check[i].value-1;
		   if(i!=check.length-1){
			   ids+=shopIds[j].value+',';
			   names+=shopNames[j].value+',';
		   }else{
			   ids+=shopIds[j].value;
			   names+=shopNames[j].value;
		   }
	    });
	window.opener.choose_shop(ids,names);
	window.close();
}
$(document).ready(function(){            
	var d="<s:property value='allIds'/>";
	var shopIds = $("input[name='shopId']");
	var check = $("input[name='radio']");
	if(d!=null&&d.length>0){
		var ary=d.split(",");
		if(ary!=null&&ary.length>0){
			for(var i=0;i<ary.length;i++){
				for(var j=0;j<shopIds.length;j++){
					if(ary[i]==shopIds[j].value){
						check[j].checked=true;
					}
				}
			}
		}
	}
});
function ok()
{ 
var temp=document.getElementsByName("radio");  
var x=null;
var bo=false;
for (var i=0;i<temp.length;i++){ 
	if(temp[i].checked) 
	 {
		
		x=temp[i].value; 
		bo=true;
	} 
	}
	if(bo==true){
		window.opener.selectShopCallBack(document.getElementById("mark"+x).value, document.getElementById("name"+x).value, document.getElementById("id"+x).value);
		window.close();
	}else{
	alert("请选择信息");	
	}

} 
</script>
 
</body>
</html>